//
//  PhotoCollectionViewCell.m
//  旅游咨询
//
//  Created by 徐斌 on 15/4/21.
//  Copyright (c) 2015年 xubin. All rights reserved.
//

#import "PhotoCollectionViewCell.h"

@implementation PhotoCollectionViewCell

- (void)dealloc
{
    [_whiteImage release];
    [_myImageView release];
    [super dealloc];
    
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubView];
    }
    return self;
}

- (void)creatSubView
{
    
//    self.contentView.frame = CGRectMake(0, 0, 375, 667);
    
    self.whiteImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WidthZ, HeighZ)];
    self.whiteImage.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.whiteImage];
    
    
    
    
    self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WidthZ * 0.946667, 500)];
    
    [self.whiteImage addSubview:self.myImageView];
    
    [_whiteImage release];
    [_myImageView release];

    
    
}




- (void)setModel:(TravelNotesDetailModel *)model
{
//    [[[self.modelArray objectAtIndex:i] photo_info] class] != [NSNull class]
    if ([model.photo_info class] != [NSNull class]) {
        NSURL *url = [NSURL URLWithString:model.photo];
        [self.myImageView sd_setImageWithURL:url];
        
        NSString *w = [ model.photo_info objectForKey:@"w"];
        NSString *h = [model.photo_info objectForKey:@"h"];
        
        CGRect fram = self.myImageView.frame;
        fram.size.height = [h floatValue] * (WidthZ * 0.946667 / [w floatValue]);
        self.myImageView.frame = fram;
        
        self.myImageView.center = CGPointMake(WidthZ / 2, HeighZ / 2);
        
        
    }
    else
    {
        CGRect frama = self.myImageView.frame;
        frama.size = CGSizeMake(0, 0);
        self.myImageView.frame = frama;
        
        
    }
    
    
}

@end
